import React, {Component} from 'react';

import Component2 from "./component2";



export default class Component1 extends Component {
    constructor(props) {
        super(props);
        this.state = {
            type:1
        };
    }

    changeClick = ()=>{
        this.setState({
            type: this.state.type === 1 ? 2 : 1
        })
    }
    render() {
        return (
            <div>
                <Component2
                    render={()=>{
                        if(this.state.type === 1){
                            return  (
                                <div>
                                    <button>type是1</button>
                                </div>
                            )
                        }else{
                            return  (
                                <div>

                                    <input type="text" value='我的type是2' />
                                </div>
                            )
                        }

                    }}
                />

                <button onClick={this.changeClick}>点我</button>
            </div>
        )
    }
}